package com.inforich.app.api.controller.common;

import com.inforich.common.core.domain.AjaxResult;
import com.inforich.common.core.domain.entity.SysDictData;
import com.inforich.common.utils.StringUtils;
import com.inforich.system.service.ISysDictTypeService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 数据字典
 * @author: HJM
 * @date: 2022/10/28
 */
@RestController
@RequestMapping("/h5api/dict")
public class AppDictController {

  @Autowired
  private ISysDictTypeService dictTypeService;

  /**
   * 根据数据类型获取数据字典
   *
   * @param dictType 字典类型
   */
  @GetMapping(value = "/type")
  public AjaxResult dictType(String dictType) {
    List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
    if (StringUtils.isNull(data)) {
      data = new ArrayList<>();
    }
    return AjaxResult.success(data);
  }

}
